Query and change propagation scheduling for heteogeneous database systems

ABSTRACT

Techniques are presented herein for efficient query processing and data change propagation at a secondary database system. The techniques involve determining execution costs for executing a query at a primary DBMS and for executing the query at an offload DBMS. The cost for executing the query at the offload DBMS includes the cost of propagating changes to database objects required by the query to the offload DBMS. Based on the execution cost, the query is sent to either the primary DBMS or the offload DBMS.

BACKGROUND

Big data analytics is a process for examining large data sets to determine patterns, correlations, trends, and other information. An emerging trend in big data analytic applications is to use a secondary database system to offload large analytic queries from a primary database system, in order to boost query processing performance. The secondary database system may act as a query processing system that does not support all features of a standard database system. For example, the secondary database system may not be able to directly receive database statements or data changes from a client application. Rather, the secondary database system may rely on the primary database system to be ACID (Atomicity, Consistency, Isolation, Durability) compliant, as expected in standard database systems.

The secondary database system may store a copy of data on which queries received at the primary database system execute. Data changes are received and executed on the primary database system. New or updated data must be added to the database of the secondary database system, and deleted data must be removed.

A possible method for propagating changes to the secondary database is propagating changes on an as-needed, on-demand basis, when data is targeted by a query. Although on-demand propagation may spread out the computing cost of propagating changes, it increases the response time required when executing a query.

Another possible method is to propagate changes as soon as they are received or committed in the primary database system. This results in a faster query response time compared to on-demand propagation, but results in high overhead for the database system when large amounts of changes are received within a short amount of time by the primary database system.

A third possible method is to schedule change propagation at specific times or at regular intervals. However, this method does not guarantee that secondary database system will have up-to-date data prior to executing a query in the secondary database system. Thus, this method does not guarantee that a query will produce accurate results.

However, for data analytics queries, such as those performed for big data analytics, data consistency is required in order for a query to produce accurate results. Furthermore, since the goal of using of a secondary system is to increase query execution efficiency, query performance cannot be significantly affected by change propagation. Thus, a method for change propagation that maintains both data consistency and query execution efficiency is required.

Additionally, most systems that use a particular propagation method require users to configure the primary and secondary database system and select a particular change propagation method based on what the user expects the database systems' workload and data change pattern to be. Once the secondary database system is configured, it may be difficult or impossible to switch between different propagation methods if the workload and/or data change pattern is not as expected.

The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.

BRIEF DESCRIPTION OF THE DRAWINGS

In the drawings:

FIG. 1 is a block diagram illustrating an example primary database system and secondary database system;

FIG. 2A is a block diagram illustrating tasks received by a primary database system;

FIG. 2B is a block diagram illustrating dependencies between tasks;

FIG. 3 is a flowchart illustrating steps for scheduling a task;

FIG. 4 is a flowchart illustrating steps for sending tasks to a secondary database system;

FIG. 5 is a block diagram illustrating a computer system that may be used to implement the techniques described herein.

DETAILED DESCRIPTION

In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present invention.

General Overview

Techniques are described for efficient query processing and data change propagation at a secondary database system. As described above, a secondary database system may be configured to execute queries, or portions thereof, received at a primary database system. Database changes made at the primary database system are copied to the secondary database system.

The primary database system includes a scheduler process that determines when, and if, queries and database changes should be sent to the secondary database system. One or more tasks are created based on a query or data change received at the primary database system. The one or more tasks are sent to the scheduler process.

The scheduler process determines whether a task depends on any other task. If a task depends on another task, then the other task needs to be processed first. For example, if a query targets a database object that was updated by a data change, then the data change needs to be made at the secondary database system before the query can be executed by the secondary database system.

Based on the task dependencies, the scheduler process can determine an order for tasks to be processed. The scheduler process may also determine whether a query should be executed at primary database system or sent to the secondary database system, based on the total time required, including propagating data changes to the secondary database system.

Thus, the database system can flexibly schedule queries and data changes in order to minimize query execution time. For example, queries that don't rely on an update can be executed before other database updates, and data changes that aren't needed by any queries can be delayed until other queries are executed.

System Overview

FIG. 1 illustrates an example primary database management system (DBMS) and an offload DBMS for the primary DBMS. Primary database system 100 comprises one or more database servers that are connected to a database 130. Database 130 may be stored on one or more disks to which primary database system 100 has access. One or more clients 110 may connect to primary database system 100. Client 110 may be a client computer system or a client application. Client 110 may submit queries and database changes for database 130 to primary database system 100.

Primary database system 100 is also connected to a secondary database system 140, which may be an offload database system for primary database system 100. In an embodiment, secondary database system 140 is configured to execute queries, or parts of queries, more efficiently than primary database system 100. Secondary database system 140 is connected to database 150. Database 150 may be stored on one or more disks to which secondary database system 150 has access. Database 150 may store a copy of at least a portion of the data stored in database 130. In an embodiment, database 150 is an asynchronous replica of database 130. As used herein, an asynchronous replica refers to a replica database wherein data may be first written to a primary database and acknowledged as being completed before being copied to a secondary database.

In an embodiment, secondary database system 140 is not configured to receive and/or handle database queries such as SQL statements from end users. Client 110 does not connect directly to secondary database system 140, or send queries or changes directly to secondary database system 140. Rather, queries and data changes from client 110 are received at primary database system 100. Primary database system 100 determines whether to send any queries, or portions thereof, to secondary database system 140 for processing. Data changes are made to database 130, and then reproduced in or copied to database 150.

Primary database system 100 also comprises a scheduler process 120. As described in further detail below, when primary database system 100 receives a query, scheduler process 120 determines if the query, or a portion thereof, should be executed by secondary database 140. Scheduler process 120 determines when, and in what order, the queries (or portions of queries) and data changes should be sent to the secondary database system 140.

As used herein, “scheduler process” refers to a database process that schedules queries and data changes. The scheduler process schedules queries and data changes to be sent to the secondary database system. In an embodiment, the scheduler process also schedules queries and data changes for execution by the primary database system.

In an embodiment, the scheduler process is a database process running on the primary database system. In an embodiment, the scheduler process is a background process that receives queries and data changes from one or more foreground database processes that receive and process queries and database updates. For example, a foreground database process may include a query coordinator or a query optimizer. The scheduler process determines if, and when, a query or database update should be sent to the secondary database system, and communicates scheduling decisions to the one or more foreground database processes. In another embodiment, the scheduler process may be the same process, or part of a group of processes, that receives and processes queries and database updates for the primary database system.

In an embodiment, the scheduler process is configured to send queries and database changes directly to the secondary database system. In another embodiment, the scheduler process communicates with a foreground process to cause queries or database changes to be sent to the secondary database system.

Task Overview

The scheduler process receives queries and data changes to be sent to the secondary database system as one or more jobs or tasks. As referred to herein, a task is a unit of work that could be sent to, and processed by, the secondary database system. The scheduler process receives two types of tasks: query tasks and update tasks.

A task may comprise task data including: one or more target database objects, the size and/or number of database objects, the amount of time required to process the task at the primary database system, the amount of time required to process the task at the secondary database system, the time at which the corresponding query or data change was received by the primary database system, the time at which the task was created, the time at which a task was received by the scheduler process, and/or a target time for completing the task (a task “deadline”).

In an embodiment, each task includes data that indicates an order in which the task was received. For example, the task may include one or more timestamps, or values, which indicate the time at which the corresponding query or data change was received by the primary database system, the task was generated by the database system, and/or when the task was received by the scheduler process.

The scheduler process maintains a task list and a priority queue. In an embodiment, the task list and priority queue are stored in memory assigned to the scheduler process. In another embodiment, the task list and priority queue are stored in memory shared by other database processes or are stored on a persistent disk.

The task list stores a list of tasks received by the scheduler process. In an embodiment, task data for each task is stored in the task list in association with the task.

The priority queue indicates an order in which tasks should be processed. In an embodiment, each task is associated with a priority value and tasks in the priority queue are stored in order of priority value. When the scheduler process sends a task to the secondary database, it selects one or more tasks from the front of the priority queue.

Query Tasks

A query task is a query, or a portion of a query, that may be offloaded to a secondary database system for processing. The query task may comprise data indicating the data objects targeted by the query task. The query task may also include data indicating an estimated cost for processing the query task in the primary database system and/or an estimated cost for processing the query task in the secondary database system.

A single query may be divided into a plurality of query tasks, based on the data required by the query. For example, database 150 may store a copy of only a portion of the data from database 130. The primary database system 100 may receive a query that targets some data that is in database 150, and some data that is only in database 130. A query task may be generated for the portion of the query that targets data stored in database 150, while the portion of the query that targets data not copied in database 150 is processed at the primary database system.

To execute a query, a DBMS first generates a query execution plan. An execution plan generated by a DBMS defines operations to be performed to execute a query and an order for performing the operations, known as plan operations. When a database instance receives a query, a query coordinator formulates a query execution plan for executing the query.

In an embodiment, a query optimizer determines whether one or more portions of the query could be executed more efficiently by the secondary database system. The query optimizer may determine the one or more portions based on, for example, the structure and contents of the query, the database objects targeted by the query, the database objects stored in the secondary database, and the types of queries that the secondary database system is configured to process. The query optimizer generates a query task for each of the one or more portions, and sends the query task to the scheduler process. For the purpose of illustrating a clear example, techniques are described with reference to queries, but may be used with portions of queries.

Update Tasks

An update task is a set of data changes to be propagated to the secondary database system. Unlike query tasks, data changes are made at both the primary database system and the secondary database system. The update task may be generated after a change has been committed in the primary database system, or generated when a data change, such as a DML (data manipulation language) statement, is received by the primary database system.

The update task may comprise data indicating changes or deletions made to the primary database. The update task may also include data indicating an estimated cost for processing the update task in the secondary database system.

In an embodiment, the data indicating data changes includes one or more identifiers associated with one or more respective database objects. For example, the data may include a plurality of row identifiers. The data may indicate the changes, additions, or deletions to be made for each respective database object. The identifiers and the changes are sent to the secondary database system as part of sending an update task to the secondary database system for processing. When the update task received by the secondary database system, the secondary database system may use the data to determine which database objects to update and what data should be modified, added, or deleted.

Task Dependency

The scheduler process determines if any dependencies exist between received tasks. If a first task depends on a second task, then the second task needs to be processed before the first task may be processed. For example, if a query depends on a database object that was updated before the query was received, then the update needs to be propagated to the secondary database system before the query can be executed at the secondary database system.

A task dependency exists when a task targets a database object that is modified by a previously received update task. A database object may include a row, a table, or a table partition. For example, assume a first update task targets a particular table. If an update task or query task, received after the first update task, also targets the particular table, then the update task or query task depends on the first update task. In contrast, if an update task or query task is received after a previous query task, the update task or query task would not depend on the previous query task, since no data was modified. Similarly, if the first update task is processed before the query or update task is received, then the query or update task does not depend on the first update task, since the data change has already been propagated.

In an embodiment, the task list includes data that indicates task dependencies. For example, the data may indicate, for each task, which tasks in the task list it depends upon. In another embodiment, the database system stores a separate mapping that indicates task dependencies. For example, the database system may store a directed graph, where each node of the graph corresponds to a task, and the edges of the graph indicate a dependency between two nodes.

Referring to FIG. 2A, it illustrates a plurality of tasks received by a scheduler process. Assume database 130 includes a table “lineItem” and a table “customer”. As illustrated in FIG. 2A, the scheduler process receives seven tasks:

-   -   At time T1, the scheduler process receives query task 212, which         targets the “lineItem” table;     -   At time T2, the scheduler process receives update task 202,         which targets the “lineItem” table, and update task 206, which         targets the “customer” table;     -   At time T3, the scheduler process receives query task 214, which         targets both the “lineItem” table and the “customer” table;     -   At time T4, the scheduler process receives update task 204,         which targets the “lineItem” table;     -   At time T5, the scheduler process receives query task 216, which         targets the “customer” table; and     -   At time T6, the scheduler process receives query task 218, which         targets the “lineItem” table.

Based on the order in which the tasks are received, the scheduler process determines what task dependencies, if any, exists between the tasks. In an embodiment, the scheduler process determines an order in which tasks are received based on a timestamp value associated with the task. The timestamp value may indicate when the task was generated or when the query or data change was received. As an example, query task 212 may be associated with a timestamp value indicating time T1. In another embodiment, the scheduler process stores each task in the task list in the order in which it was received by the scheduler process.

FIG. 2B illustrates task dependencies for the received tasks.

If a task targets a database object that was not targeted by a previously received update task, then the task does not depend on any tasks. For example, query task 212 is received before any update tasks that targets the “lineItem” table, so it does not depend on any tasks. Similarly, update tasks 202 and 206 were received before any updates that target their respective tables, so update task 202 and 206 also do not depend on any tasks.

If a task is received after an update task and targets the same database object as the update task, then it depends on the update task. For example, update task 204 is received after update task 202 and both update tasks target the “lineItem” table. Thus, update task 204 depends on update task 202.

A task may depend, either directly or indirectly, on more than one update tasks. For example, query task 218 is received after update task 204 and also targets the “lineItem” table. Thus, query task 218 depends on update task 204. Query task 218 also indirectly depends on update task 202, since update task 204 depends on update task 202. Thus, query task 218 requires both update task 202 and update task 204 to process prior to being executed.

As another example, query task 214 is received after update task 202 and update task 206. Query task 214 targets the “lineItem” table, which was updated by update task 202. Query task 214 also targets the “customer” table, which was updated by update task 206. Thus, query task 214 depends on both update task 202 and update task 206.

Task Cost

Each task may be associated with a task cost. A task cost is an estimated amount of time for a task to be processed by a database system.

The task cost for an update task is an estimated amount of time for propagating the update to the secondary database system. In an embodiment, the cost is based on the initial cost of populating the secondary database system. When the secondary database system is first configured and initialized, data is copied from the primary database system to the secondary database system. Based on the amount of data copied from the primary database system and the amount required to copy the data, the primary database system can compute an average time for propagating data. For example, a number of rows may initially be copied to the secondary database system and an average amount of time per row may be calculated. An estimated amount of time for an update task may be computed based on the average amount of time per row and the number of rows targeted by the update task.

In an embodiment, the database system may update the average time for data propagation by tracking the amount of time taken by each update task and the amount of data targeted by each update task. The updated average time may be used for estimating a cost for subsequent update tasks.

The task cost for a query task is an estimated execution cost for the query. A query task may be associated with two execution costs: an execution cost for executing the query in the primary database system and an execution cost for executing the query in the secondary database system.

An execution cost for executing a query task may be calculated by a query optimizer. In an embodiment, the process scheduler requests the execution cost from the query optimizer after it receives a task. In another embodiment, the query optimizer determines whether a query is a candidate for processing in the secondary database system. The query optimizer may determine that the query is a candidate for processing in the secondary database system if the execution cost for executing in the secondary database system is less than the execution cost for executing in the primary database system. The task data for the query task may include the primary database system execution cost and the secondary database system execution cost.

In an embodiment, the execution cost for a query task includes the cost of propagating changes to database objects required by the query task. If one or more tasks need to be processed prior to processing the query task, the execution cost of each of the one or more tasks is added to the execution cost for processing the query task. In an embodiment, the scheduler process determines task dependencies for a task and calculates an updated secondary database system execution cost based on task dependencies for the query task. For example, referring to query task 218, the total task cost includes the execution cost of the query at the secondary database system, as well as the task cost for update task 202 and update task 204.

Scheduling Tasks

When the scheduler process receives a query task, it determines either: 1) the query task should be sent to the secondary database system; 2) the query task should be processed in the primary database system; or 3) the query task should wait before processing. Waiting to process the query task may include waiting for other query tasks to be processed and/or waiting for database updates to be propagated to the secondary database system.

FIG. 3 illustrates a flowchart for scheduling tasks received by a scheduler process.

At step 300, the scheduler process receives a task. The scheduler process adds the received task and task data to the task list. In an embodiment, the scheduler process adds data indicating a time at which the task was received to the task data. For the purpose of illustration, assume scheduler process 120 receives query task 218.

At step 302, the scheduler process determines if the received task depends on any previously received tasks. As described above, the task dependencies are used to determine an estimated execution time for processing the task on the secondary database system. The scheduler process stores the dependency data in a task dependency mapping. In the present example, scheduler process 120 determines that query task 218 depends on task 204, which depends on task 202.

At step 304, the scheduler process determines the task costs for the task. If the task is a query task, the scheduler process determines the execution cost for processing the task at the primary database system and the secondary database system. In an embodiment, the scheduler process requests the execution costs for the query task from a query optimizer. In another embodiment, the execution cost for the query task is stored in the task data received by the scheduler process.

As described above, the execution cost for a query task on the secondary database system includes the costs for any update tasks that the query task depends on. Based on the dependencies determined in step 302, the scheduler process determines the total execution cost for processing the task at the secondary database system. In the present example, the total execution cost for task 218 includes the task cost for task 204 and the task cost for task 202.

At step 306, the scheduler process determines whether to execute a task in a primary database system or a secondary database system. An update task is always processed by the secondary database system. A query task may be processed by a secondary database system or the primary database system based on the respective execution costs.

In an embodiment, each task is associated with a deadline. The scheduler process may determine the deadline based on the task cost and store the deadline in task data. As referred to herein, a deadline is a time by which a task should be executed. The deadline for a query task is based on the execution cost for the primary database system. For example, the deadline for query task may be the time at which the query task is received, plus the primary database execution cost.

The deadline for an update task is based on the tasks that depend on the update task. If one or more tasks depend on the update task, then the deadline for the update task is the shortest deadline from the respective deadlines of the one or more tasks. In an embodiment, if the received task depends on an update task, then the deadline for the update task may be updated based on the deadline for the received task. If no task depends on the update task, then the update task has no deadline. In an embodiment, if the task has no deadline, then the deadline may be indicated in task data by a large value.

The current time, or the time at which the task was received, plus the total execution cost for processing a query task on the secondary database system, is compared with the deadline to determine whether the query task will meet the deadline. If a query task will not meet the deadline, then the scheduler process determines that the query task should be processed in the primary database system. For example, if the current time plus the total execution cost at secondary database system for query task 218 will exceed the deadline, then scheduler process 120 determines that task 218 should be executed at the primary database system.

If a query task will meet the deadline, then the scheduler process determines that the task should be executed in the secondary database system. In an embodiment, when the scheduler process determines that a task should be sent to the secondary database system, it sends the task to the secondary database system or notifies a foreground process that the task should be sent to the secondary database system.

In another embodiment, the scheduler process adds tasks that will be sent to the secondary database system to a priority queue. Each task is associated with a priority value and tasks in the priority queue are sorted based on the priority value. The scheduler process may be configured to assign priorities to tasks based on optimization goals for the database systems, such as maximizing secondary database system usage and minimizing query execution time.

The priority value of a task may also be based on the task deadline. For example, the priority value may be the inverse of the task deadline, such that tasks with an earlier deadline may be added to the front of the queue, while tasks with a later deadline or no deadline (i.e., an update task with no dependent tasks) may be added to the end of the queue.

In an embodiment, the scheduler process adds a task to the priority queue when it is ready to be sent to the secondary database system. A task is ready to be sent if it does not depend on any other tasks. If a task depends on another task, the task remains in the task list and is not added to the priority queue. Once the task it depends on is removed from the priority queue, the scheduler process adds the task to the priority queue.

Completeting Scheduled Tasks

After tasks are added to the priority queue, the scheduler process periodically selects one or more tasks to be sent to the secondary database system. FIG. 4 illustrates a flowchart for sending scheduled tasks to secondary database.

At step 400, the scheduler process selects one or more tasks from the priority queue to send to the secondary database system. In an embodiment, the number of tasks is based on the number of tasks the secondary database system can process concurrently. For example, if the secondary database system processes tasks serially, then the scheduler process may select a single task. If the secondary database system processes tasks in parallel, for example, if the secondary database system is a multi-node database system, then the scheduler process may select a plurality of tasks to be processed in parallel.

In an embodiment, the scheduler process sends the task to the secondary database system directly. In another embodiment, the scheduler process notifies a foreground database process of the scheduling decision, and the foreground database process sends the task to the secondary database.

At step 402, the one or more selected tasks are removed from the task list and the priority queue. In an embodiment, the tasks are removed from the task list after the secondary database system has indicated that the tasks were completed. For example, the secondary database system may send a message to the primary database system when a data change has been completed or when a query has finished processing. As another example, the secondary database system may send the results for a query to the primary database system when it has finished processing the query.

At step 404, the task dependencies for remaining tasks are updated. Updating the task dependencies may include determining which tasks depended on the completed task and re-calculating their estimated cost based on the actual time taken to complete the task, removing the completed task from a task dependency mapping, and/or adding newly received tasks to the priority queue.

For example, if a subsequently received task requires a database object that was updated by the completed task, the received task would not depend on the completed task, since the completed task has been removed from the task list and the task dependency mapping. In other words, the cost of processing the received task at the secondary database system would not include the cost of processing the completed task, since the task has already been completed.

At step 406, the scheduler process updates the priority queue to determine if remaining query tasks should still be sent to the secondary database system. In an embodiment, the scheduler process determines whether each query task could still be processed before their respective deadline. The scheduler process may compare the deadline for each query task with the current time and estimated time for processing in the secondary database system. If the estimated processing time exceeds the deadline, then the scheduler process may determine that the query task should be processed at the primary database system.

In an embodiment, the scheduler process may notify a foreground process that the task should be processed at the primary database system. In another embodiment, the scheduler process schedules the task to be processed by the primary database system.

In an embodiment, if the scheduler process determines that the query task should be processed at the primary database system, the query task is removed from the task list and the priority queue. The deadline for update tasks that the query task depended on are updated, if necessary, and the priority queue may be re-sorted based on the updated deadlines.

If tasks remain in the priority queue, the process returns to step 400 to select one or more new tasks to process.

DBMS Overview

Embodiments of the present invention are used in context of DBMSs. Therefore, a description of a DBMS is useful.

A DBMS manages one or more databases. A DBMS may comprise one or more database servers. A database comprises database data and a database dictionary that are stored on a persistent memory mechanism, such as a set of hard disks. Database data may be stored in one or more database containers. Each container contains records. The data within each record is organized into one or more fields. In relational DBMSs, the data containers are referred to as tables, the records are referred to as rows, and the fields are referred to as columns. In object-oriented database, the data containers are referred to as object classes, the records are referred to as objects, and the fields are referred to as attributes. Other database architectures may use other terminology.

A database block, also referred to as a data block, is a unit of persistent storage. A database block is used by a database server to store database records (e.g., to store rows of a table, to store column values of a column). When records are read from persistent storage, a database block containing the record is copied into a database block buffer in RAM memory of a database server. A database block usually contains multiple rows, and control and formatting information (e.g., offsets to sequences of bytes representing rows or other data structures, list of transactions affecting a row). A database block may be referenced by a database block address.

A multi-node database management system is made up of interconnected nodes that share access to the same database or databases. Typically the nodes are interconnected via a network and share access, in varying degrees, to shared storage, e.g. shared access to a set of disk drives and data blocks stored thereon. The nodes in the multi-node database system may be in the form of a group of computers (e.g. work stations, personal computers) that are interconnected via a network. Alternately, the nodes may be the nodes of a grid, which is composed of nodes in the form of server blades interconnected with other server blades on a rack.

Each node in a multi-node database system may host a database server. A server, such as a database server, is a combination of integrated software components and an allocation of computational resources, such as memory, a node, and processes on the node for executing the integrated software components on a processor, the combination of the software and computation resources being dedicated to performing a particular function on behalf of one or more clients.

Hardware Overview

According to one embodiment, the techniques described herein are implemented by one or more special-purpose computing devices. The special-purpose computing devices may be hard-wired to perform the techniques, or may include digital electronic devices such as one or more application-specific integrated circuits (ASICs) or field programmable gate arrays (FPGAs) that are persistently programmed to perform the techniques, or may include one or more general purpose hardware processors programmed to perform the techniques pursuant to program instructions in firmware, memory, other storage, or a combination. Such special-purpose computing devices may also combine custom hard-wired logic, ASICs, or FPGAs with custom programming to accomplish the techniques. The special-purpose computing devices may be desktop computer systems, portable computer systems, handheld devices, networking devices or any other device that incorporates hard-wired and/or program logic to implement the techniques.

For example, FIG. 5 is a block diagram that illustrates a computer system 500 upon which an embodiment of the invention may be implemented. Computer system 500 includes a bus 502 or other communication mechanism for communicating information, and a hardware processor 504 coupled with bus 502 for processing information. Hardware processor 504 may be, for example, a general purpose microprocessor.

Computer system 500 also includes a main memory 506, such as a random access memory (RAM) or other dynamic storage device, coupled to bus 502 for storing information and instructions to be executed by processor 504. Main memory 506 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 504. Such instructions, when stored in non-transitory storage media accessible to processor 504, render computer system 500 into a special-purpose machine that is customized to perform the operations specified in the instructions.

Computer system 500 further includes a read only memory (ROM) 508 or other static storage device coupled to bus 502 for storing static information and instructions for processor 504. A storage device 510, such as a magnetic disk, optical disk, or solid-state drive is provided and coupled to bus 502 for storing information and instructions.

Computer system 500 may be coupled via bus 502 to a display 512, such as a cathode ray tube (CRT), for displaying information to a computer user. An input device 514, including alphanumeric and other keys, is coupled to bus 502 for communicating information and command selections to processor 504. Another type of user input device is cursor control 516, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 504 and for controlling cursor movement on display 512. This input device typically has two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), that allows the device to specify positions in a plane.

Computer system 500 may implement the techniques described herein using customized hard-wired logic, one or more ASICs or FPGAs, firmware and/or program logic which in combination with the computer system causes or programs computer system 500 to be a special-purpose machine. According to one embodiment, the techniques herein are performed by computer system 500 in response to processor 504 executing one or more sequences of one or more instructions contained in main memory 506. Such instructions may be read into main memory 506 from another storage medium, such as storage device 510. Execution of the sequences of instructions contained in main memory 506 causes processor 504 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions.

The term “storage media” as used herein refers to any non-transitory media that store data and/or instructions that cause a machine to operate in a specific fashion. Such storage media may comprise non-volatile media and/or volatile media. Non-volatile media includes, for example, optical disks, magnetic disks, or solid-state drives, such as storage device 510. Volatile media includes dynamic memory, such as main memory 506. Common forms of storage media include, for example, a floppy disk, a flexible disk, hard disk, solid-state drive, magnetic tape, or any other magnetic data storage medium, a CD-ROM, any other optical data storage medium, any physical medium with patterns of holes, a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip or cartridge.

Storage media is distinct from but may be used in conjunction with transmission media. Transmission media participates in transferring information between storage media. For example, transmission media includes coaxial cables, copper wire and fiber optics, including the wires that comprise bus 502. Transmission media can also take the form of acoustic or light waves, such as those generated during radio-wave and infra-red data communications.

Various forms of media may be involved in carrying one or more sequences of one or more instructions to processor 504 for execution. For example, the instructions may initially be carried on a magnetic disk or solid-state drive of a remote computer. The remote computer can load the instructions into its dynamic memory and send the instructions over a telephone line using a modem. A modem local to computer system 500 can receive the data on the telephone line and use an infra-red transmitter to convert the data to an infra-red signal. An infra-red detector can receive the data carried in the infra-red signal and appropriate circuitry can place the data on bus 502. Bus 502 carries the data to main memory 506, from which processor 504 retrieves and executes the instructions. The instructions received by main memory 506 may optionally be stored on storage device 510 either before or after execution by processor 504.

Computer system 500 also includes a communication interface 518 coupled to bus 502. Communication interface 518 provides a two-way data communication coupling to a network link 520 that is connected to a local network 522. For example, communication interface 518 may be an integrated services digital network (ISDN) card, cable modem, satellite modem, or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, communication interface 518 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN. Wireless links may also be implemented. In any such implementation, communication interface 518 sends and receives electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.

Network link 520 typically provides data communication through one or more networks to other data devices. For example, network link 520 may provide a connection through local network 522 to a host computer 524 or to data equipment operated by an Internet Service Provider (ISP) 526. ISP 526 in turn provides data communication services through the world wide packet data communication network now commonly referred to as the “Internet” 528. Local network 522 and Internet 528 both use electrical, electromagnetic or optical signals that carry digital data streams. The signals through the various networks and the signals on network link 520 and through communication interface 518, which carry the digital data to and from computer system 500, are example forms of transmission media.

Computer system 500 can send messages and receive data, including program code, through the network(s), network link 520 and communication interface 518. In the Internet example, a server 530 might transmit a requested code for an application program through Internet 528, ISP 526, local network 522 and communication interface 518.

The received code may be executed by processor 504 as it is received, and/or stored in storage device 510, or other non-volatile storage for later execution.

In the foregoing specification, embodiments of the invention have been described with reference to numerous specific details that may vary from implementation to implementation. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense. The sole and exclusive indicator of the scope of the invention, and what is intended by the applicants to be the scope of the invention, is the literal and equivalent scope of the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction. 

What is claimed is:
 1. A method comprising: receiving a query at a primary database management system (DBMS) comprising a primary database, an offload DBMS, and an offload database replica accessed by said offload DBMS to calculate query operations requested by said primary DBMS, said offload database replica being an asynchronous replica of at least a portion of said primary database; calculating a first execution cost for executing the query on the primary DBMS; calculating a second execution cost for executing the query on said offload DBMS, based on synchronization of data changes, made at the primary DBMS, with said offload database replica, wherein said data changes are to one or more database objects for which access is required by execution of the query; and sending the query to either the primary DBMS or the offload DBMS, based on the first execution cost and the second execution cost.
 2. The method of claim 1, further comprising: sending the query to the primary DBMS if the first execution cost is less than the second execution cost; or sending the query to the offload DBMS if the first execution cost is greater than the second execution cost.
 3. The method of claim 1 wherein the offload DBMS is configured to process at least some queries more efficiently than the primary DBMS.
 4. The method of claim 1 wherein the query comprises one or more query portions, and the calculating and sending are performed for each query portion of the one or more query portions.
 5. The method of claim 1 further comprising: synchronizing data changes to one or more database objects for which access is required by execution of the query, prior to sending the query to the offload DBMS.
 6. The method of claim 1 further comprising: wherein said data changes include data changes to one or more database objects for which access is not required by execution of the query; and sending the query to the offload DBMS prior to synchronizing the data changes to the one or more database objects for which access is not required by execution of the query.
 7. The method of claim 1 further comprising: storing a mapping that indicates which data changes are to database objects for which access is required; and calculating the second execution cost based on the mapping.
 8. The method of claim 1 further comprising: storing a queue for sending queries and data changes to the offload DBMS; wherein sending the query to the offload DBMS comprises adding the query to the queue.
 9. The method of claim 8 further comprising adding the query to the queue based on a priority value.
 10. The method of claim 8 further comprising selecting a query or data change from the queue to send to the offload DBMS.
 11. The method of claim 10 further comprising: in response to selecting a query or data change from the queue, for each query in the queue: determining an updated second execution cost; and sending the query to the primary DBMS if the updated second execution cost is greater than the first execution cost.
 12. One or more non-transitory computer-readable media storing instructions which, when executed by one or more hardware processors, cause: receiving a query at a primary database management system (DBMS) comprising a primary database, an offload DBMS, and an offload database replica accessed by said offload DBMS to calculate query operations requested by said primary DBMS, said offload database replica being an asynchronous replica of at least a portion of said primary database; calculating a first execution cost for executing the query on the primary DBMS; calculating a second execution cost for executing the query on said offload DBMS, based on synchronization of data changes, made at the primary DBMS, with said offload database replica, wherein said data changes are to one or more database objects for which access is required by execution of the query; and sending the query to either the primary DBMS or the offload DBMS, based on the first execution cost and the second execution cost.
 13. The one or more non-transitory computer-readable media of claim 12, wherein the instructions include instructions that, when executed by the one or more processors, further cause: sending the query to the primary DBMS if the first execution cost is less than the second execution cost; or sending the query to the offload DBMS if the first execution cost is greater than the second execution cost.
 14. The one or more non-transitory computer-readable media of claim 12 wherein the offload DBMS is configured to process at least some queries more efficiently than the primary DBMS.
 15. The one or more non-transitory computer-readable media of claim 12 wherein the query comprises one or more query portions, and the calculating and sending are performed for each query portion of the one or more query portions.
 16. The one or more non-transitory computer-readable media of claim 12, wherein the instructions include instructions that, when executed by the one or more processors, further cause: synchronizing data changes to one or more database objects for which access is required by execution of the query, prior to sending the query to the offload DBMS.
 17. The one or more non-transitory computer-readable media of claim 12, wherein the instructions include instructions that, when executed by the one or more processors, further cause: wherein said data changes include data changes to one or more database objects for which access is not required by execution of the query; and sending the query to the offload DBMS prior to synchronizing the data changes to the one or more database objects for which access is not required by execution of the query.
 18. The one or more non-transitory computer-readable media of claim 12, wherein the instructions include instructions that, when executed by the one or more processors, further cause: storing a mapping that indicates which data changes are to database objects for which access is required; and calculating the second execution cost based on the mapping.
 19. The one or more non-transitory computer-readable media of claim 12, wherein the instructions include instructions that, when executed by the one or more processors, further cause: storing a queue for sending queries and data changes to the offload DBMS; wherein sending the query to the offload DBMS comprises adding the query to the queue.
 20. The one or more non-transitory computer-readable media of claim 19, wherein the instructions include instructions that, when executed by the one or more processors, further cause adding the query to the queue based on a priority value.
 21. The one or more non-transitory computer-readable media of claim 19, wherein the instructions include instructions that, when executed by the one or more processors, further cause selecting a query or data change from the queue to send to the offload DBMS.
 22. The one or more non-transitory computer-readable media of claim 21, wherein the instructions include instructions that, when executed by the one or more processors, further cause: in response to selecting a query or data change from the queue, for each query in the queue: determining an updated second execution cost; and sending the query to the primary DBMS if the updated second execution cost is greater than the first execution cost. 